package com.yunying.rispro.service.impl;

import com.yunying.rispro.exception.BusinessException;
import com.yunying.rispro.model.Diagnose;
import com.yunying.rispro.mapper.DiagnoseMapper;
import com.yunying.rispro.service.IDiagnoseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunying.rispro.util.JsonResponseBody;
import com.yunying.rispro.util.JsonResponseStatus;
import com.yunying.rispro.util.PageBean;
import com.yunying.rispro.vo.RisVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 诊断信息表 服务实现类
 * </p>
 *
 * @author yunying
 * @since 2022-04-21
 */
@Service
public class DiagnoseServiceImpl extends ServiceImpl<DiagnoseMapper, Diagnose> implements IDiagnoseService {

    @Autowired
    private DiagnoseMapper diagnoseMapper;

    @Override
    public JsonResponseBody<?> addDiagnose(Diagnose diagnose) {
        diagnose.setDiagnoseId(20+new Date().getTime());
        int i=diagnoseMapper.insertDiagnose(diagnose);
        if(i<0){
            throw new BusinessException(JsonResponseStatus.OPERATE_ERROR);
        }
        return new JsonResponseBody<>();
    }

    @Override
    public JsonResponseBody<List<Map<String, Object>>> queryHisPager(RisVo risVo, PageBean pageBean) {
        List<Map<String, Object>> maps = diagnoseMapper.selectHisList(risVo);
        return new JsonResponseBody<>(maps);
    }
}
